package cn.bigcontainer.alt.meta.po;

import java.util.ArrayList;
import java.util.List;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;

import cn.bigcontainer.alt.common.entity.BigMap;
import cn.bigcontainer.alt.common.po.BasePo;
import cn.bigcontainer.alt.common.po.Po;
import cn.bigcontainer.alt.common.util.WoKit;
import cn.bigcontainer.alt.meta.typehandler.BigMapHandler;
import cn.bigcontainer.alt.meta.typehandler.MPropertyListHandler;
import cn.bigcontainer.alt.meta.typehandler.MRelationListHandler;
import lombok.Data;
import lombok.experimental.Accessors;
import lombok.extern.slf4j.Slf4j;

/**
 * 对象，和数据库表映射
 * @author cailei
 * @date 2019-12-04
 */
@Slf4j
@Data
@TableName(autoResultMap = true)
@Accessors(chain = true)
public class MObject extends BasePo {

	@TableId
	protected String id;//64

	protected String no;//64

	protected String name;//100

	protected Integer idx;

	protected String module;// 100

	/**
	 * 0-关系表，1-普通表
	 */
	protected Integer status;

	protected String description;//500

	/**
	 * 特殊字段数据json，例如修改时间字段、创建时间字段等
	 */
	@TableField(typeHandler = BigMapHandler.class)
	protected BigMap<String, Object> columns = new BigMap<>();// text

	@TableField(typeHandler = MPropertyListHandler.class)
	protected List<MProperty> properties = new ArrayList<>();// text

	@TableField(typeHandler = MRelationListHandler.class)
	protected List<MRelation> relations = new ArrayList<>();// text

	@TableField(typeHandler = BigMapHandler.class)
	protected BigMap<String, Object> data = new BigMap<>();// text

	public MObject(Po po) {
		WoKit.cloneBySetter(po, this);
	}

	public MObject() {

	}
}
